package com.elitel.frame.business.service.common.config;

import com.elitel.frame.business.service.common.impl.CommonServerExecutor;
import com.elitel.frame.business.service.common.processor.RequestCheckProcessor;
import com.elitel.frame.business.service.common.processor.ResponseConversionProcessor;
import com.elitel.frame.business.service.impl.SingleTableSqlPolymerServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mulis
 */
@Configuration
public class CommonServiceConfig {

    @Bean
    public CommonServerExecutor commonServerExecutor() {
        CommonServerExecutor executor = new CommonServerExecutor();
        // 1.添加前置处理逻辑
        executor.addPre(new RequestCheckProcessor());
        // 2.注册服务
        executor.registerService("singleTableServer", CommonServerExecutor.Config.set(SingleTableSqlPolymerServer.class));
        executor.registerService("executeSqlServer", CommonServerExecutor.Config.set(SingleTableSqlPolymerServer.class));
        executor.registerService("polymerServer", CommonServerExecutor.Config.set(SingleTableSqlPolymerServer.class));
        // 3.添加后置处理逻辑
        // executor.addPost(new ResponseConversionProcessor());
        return executor;
    }

}
